Buzzer : Buzzer device
This module is a General Buzzer operation module.
User can use the following code to import the Buzzer module.
var Buzzer = require('buzzer');
Support
The following shows Buzzer module APIs available for each permissions.
| User Mode | Privilege Mode | |
|---|---|---|
| Buzzer | ● | |
| Buzzer.open | ● | |
| buzzer.close | ● | |
| buzzer.beep | ● | |
| buzzer.flush | ● |
Buzzer Class
new Buzzer()
- Returns: {Object} Returns buzzer object.
Open buzzer object, an exception will be thrown if it fails to open.
Buzzer.open()
- Returns: {Object} Returns buzzer object.
Open buzzer object, return undefined if it fails to open.
Example
var buzzer = new Buzzer();
var buzzer = Buzzer.open();
Buzzer Object
buzzer.close()
Close this buzzer and reclaiming file descriptors. If user forgets to call this function, the file descriptor is automatically reclaimed when the object is destroyed.
buzzer.beep(param)
param{Object} Buzzer control parameters.- Returns: {Boolean} Whether the operation was successful.
param is the control parameter object, it can contain the following members:
hz{Integer} Sound frequency. The human ear can hear sound frequency of 20 ~ 20KHz, the default is 5KHz.time{Integer} The execution time of this command, in milliseconds.beep{Boolean} Tweet or mute.
Send a command to the buzzer.
Example
buzzer.beep({ time: 200 });
buzzer.flush()
Clear the buzzer command queue and stop beeping.
Example
buzzer.beep({ time: 200 });
buzzer.flush();




陕公网安备61019002002605号